package huv.andlogin;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;


public class Cfg {
	private String _url;
	private String _name;
	private String _essid;
	private HashMap<String,String> _requestProperty;
	private HashMap<String,String> _postRequest;
	public Cfg(String name,String essid){
		setName(name);
		setEssid(essid);
		_requestProperty = new HashMap<String,String>();
		_postRequest = new HashMap<String,String>();
			
	}
	public void addRequestProperty(String key,String value){
		_requestProperty.put(key, value);
	}
	public int countRequestProperty(){
		return _requestProperty.size();
	}
	public Iterator<?> getRPIterator(){
		return _requestProperty.entrySet().iterator();
	}
	public void setEssid(String _essid) {
		this._essid = _essid;
	}
	public String getEssid() {
		return _essid;
	}
	public void setName(String _name) {
		this._name = _name;
	}
	public String geName() {
		return _name;
	}
	public void addPostRequest(String k,String p) {
		_postRequest.put(k,p);
	}
	public Iterator<?> getPRIterator(){
		return _postRequest.entrySet().iterator();
	}
	public void setUrl(String _url) {
		this._url = _url;
	}
	public String getUrl() {
		return _url;
	}
	public String getPostString(){
		String s="";
		Boolean first=true;
		@SuppressWarnings("unchecked")
		Iterator<Entry<String,String>> i = (Iterator<Entry<String, String>>) getPRIterator();
		while(i.hasNext()){
			if(!first) s+="&";
			Entry<String,String> t = i.next();
			s+=t.getKey()+"="+t.getValue();
			first=false;
		}
		return s;
	}
}
